﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Laurent_Data
{
	public class LastWorkingDays
	{
		private Int32 days = 5;
		private List<DateTime> listHoliday = new List<DateTime>();
		private List<DateTime> listWorkingDay = new List<DateTime>();

		public List<DateTime> GetLastWorkingDays( DateTime date )
		{
			List<DateTime> _listDate = new List<DateTime>(); // Não está mais sendo utilizada.
			Int32 _days = 0;

			while( _days < days )
			{
				date = date.AddDays( -1 );

				if( date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday )
				{
					continue;
				}

				if( listHoliday.Contains( date ) )
				{
					continue;
				}

				listWorkingDay.Add( date );
				_days++;
			}
			
			// Modificação LUIZ: Retornar a lista listWorkingDay / Antes retornava a _listDate
			return listWorkingDay;
		}

		private void loadListHoliday()
		{
			listHoliday.Add( new DateTime( 2012, 1, 1 ) );
			listHoliday.Add( new DateTime( 2012, 2, 21 ) );
			listHoliday.Add( new DateTime( 2012, 12, 25 ) );
			listHoliday.Add( new DateTime( 2012, 12, 31 ) );
		}
	}
}
